/*
 * @lc app=leetcode.cn id=1 lang=javascript
 *
 * [1] 两数之和
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function(nums, target) {
    let reduceLength = 0
    let res = []
    while(nums.length > 0) {
        let first = nums.shift()
        nums.some((e,i) => {
            if ( first + e === target) {
                res = [reduceLength, reduceLength + i + 1]
                return true
            }
        })
        reduceLength++
        if (res.length !== 0) {
            break
        }
    } 
    return res
};
// @lc code=end

